package com.yx.learn.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Company entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tcompany", catalog = "yx_01")
public class Company implements java.io.Serializable {

	// Fields

	private Integer id;
	private String companyCode;
	private String companyName;
	private String telephone;
	private String email;
	private String fax;
	private String address;
	private Date createTime;
	private String memo;
	private Set<Role> roles = new HashSet<Role>(0);
	private Set<Group> groups = new HashSet<Group>(0);
	private Set<Department> departments = new HashSet<Department>(0);

	// Constructors

	/** default constructor */
	public Company() {
	}

	/** minimal constructor */
	public Company(Integer id, String companyCode, String companyName,
			Date createTime) {
		this.id = id;
		this.companyCode = companyCode;
		this.companyName = companyName;
		this.createTime = createTime;
	}

	/** full constructor */
	public Company(Integer id, String companyCode, String companyName,
			String telephone, String email, String fax, String address,
			Date createTime, String memo, Set<Role> roles,
			Set<Group> groups, Set<Department> departments) {
		this.id = id;
		this.companyCode = companyCode;
		this.companyName = companyName;
		this.telephone = telephone;
		this.email = email;
		this.fax = fax;
		this.address = address;
		this.createTime = createTime;
		this.memo = memo;
		this.roles = roles;
		this.groups = groups;
		this.departments = departments;
	}

	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "companyCode", nullable = false, length = 20)
	public String getCompanyCode() {
		return this.companyCode;
	}

	public void setCompanyCode(String companyCode) {
		this.companyCode = companyCode;
	}

	@Column(name = "companyName", nullable = false, length = 64)
	public String getCompanyName() {
		return this.companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	@Column(name = "telephone", length = 20)
	public String getTelephone() {
		return this.telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	@Column(name = "email", length = 64)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "fax", length = 200)
	public String getFax() {
		return this.fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	@Column(name = "address", length = 200)
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "createTime", nullable = false, length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "memo", length = 200)
	public String getMemo() {
		return this.memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "company")
	public Set<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "company")
	public Set<Group> getGroups() {
		return this.groups;
	}

	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}

	//@OneToMany( fetch = FetchType.LAZY, mappedBy = "company")
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "company")
	public Set<Department> getDepartments() {
		return this.departments;
	}

	public void setDepartments(Set<Department> departments) {
		this.departments = departments;
	}

}